//
//  HJCommonTableHeaderView.m
//  GAMCAfterSales
//
//  Created by 贺佳 on 2018/5/16.
//  Copyright © 2018年 glendale. All rights reserved.
//

#import "HJCommonTableHeaderView.h"

@implementation HJCommonTableHeaderView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame]) {
        self.backgroundColor = [[UIColor alloc]initWithRed:0.96 green:0.96 blue:0.96 alpha:1];
    }
    return self;
}
-(void)setTitleAry:(NSArray *)titleAry
{
    _titleAry=titleAry;
    CGFloat labelW=self.mj_w/titleAry.count;
    for(int i = 0; i <titleAry.count;i++)
    {
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(i*labelW, 0, labelW, self.mj_h)];
        titlelabel.backgroundColor = [UIColor clearColor];
        titlelabel.text = [titleAry objectAtIndex:i];
        titlelabel.textColor = [UIColor grayColor];
        titlelabel.font = [UIFont fontWithName:@"ArialMT" size:16];
        [titlelabel setTextAlignment:NSTextAlignmentCenter];
        [self addSubview:titlelabel];
    }
}
-(void)setTitleColor:(UIColor *)titleColor
{
    _titleColor=titleColor;
    for (UILabel*label in self.subviews) {
        label.textColor=titleColor;
    }
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat labelW=self.mj_w/self.titleAry.count;
    int i=0;
    for (UILabel*label in self.subviews) {
        label.frame=CGRectMake(i*labelW, 0, labelW, self.mj_h);
        i++;
    }
}
@end
